package wiki.douzi.helpyougrow.service.impl;

import wiki.douzi.helpyougrow.domain.FoodsCategory;
import wiki.douzi.helpyougrow.mapper.FoodsCategoryMapper;
import wiki.douzi.helpyougrow.service.FoodsCategoryService;
import org.springframework.stereotype.Service;

import java.util.List;
import javax.annotation.Resource;

/**
 * (FoodsCategory)表服务实现类
 *
 * @author Douzi
 * @since 2022-06-18 16:39:24
 */
@Service("foodsCategoryService")
public class FoodsCategoryServiceImpl implements FoodsCategoryService {
    @Resource
    private FoodsCategoryMapper foodsCategoryMapper;

    /**
     * 查询所有数据
     *
     * @return 实例对象集合
     */
    @Override
    public List<FoodsCategory> queryAll() {
        return this.foodsCategoryMapper.queryAll();
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public FoodsCategory queryById(Integer id) {
        return this.foodsCategoryMapper.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param foodsCategory 实例对象
     * @return 实例对象
     */
    @Override
    public FoodsCategory insert(FoodsCategory foodsCategory) {
        this.foodsCategoryMapper.insert(foodsCategory);
        return foodsCategory;
    }

    /**
     * 修改数据
     *
     * @param foodsCategory 实例对象
     * @return 实例对象
     */
    @Override
    public FoodsCategory update(FoodsCategory foodsCategory) {
        this.foodsCategoryMapper.update(foodsCategory);
        return this.queryById(foodsCategory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.foodsCategoryMapper.deleteById(id) > 0;
    }
}

